package itheima.d07;

import java.util.ArrayList;
import java.util.List;

public class Test {
    public static void main(String[] args) {
        List <String> list =new ArrayList<>();
        list.add("张无忌");
        list.add("周芷若");
        list.add("赵敏");
        list.add("张强");
        list.add("张三丰");

        List<String> list1 =new ArrayList<>();
        for (String s : list) {
            if (s.startsWith("张")&&s.length()==3  ) {
                list1.add(s);
            }
        }

        list1.forEach(System.out::println);


        System.out.println("------------------");





        List<String>newList2 = list.stream().filter(s -> s.startsWith("张") && s.length() == 3).toList();
        newList2.forEach(System.out::println);
    }
}
